<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function sum(hao){
               var q = +prompt('请输入第一个数');
               var e = +prompt('请输入第二个数');
               switch(hao){
                   case '+':
                    alert(q + e);
                   break;
                   case '-':
                   alert(q - e);
                   break;
                   case '*':
                   alert(q * e);
                   break;
                   default :
                   alert(q / e);
                   break;
               }
        }
        sum('+');
    </script>
</body>
</html>